﻿Imports System.Text
Imports DotNetNuke.Modules.GeminorumSoftwareContacts.Data

<TestClass()>
Public Class ContactToSQLParameterConverterTests

#Region "---TestGetUpdateParameterList---"
    <TestMethod()>
    Public Sub TestGetUpdateParameterList()
        Dim target As New DotNetNuke.Modules.GeminorumSoftwareContacts.ContactToSQLParameterConverter
        Dim testContact As New DotNetNuke.Modules.GeminorumSoftwareContacts.Contact
        testContact.CellPhoneNumber = "CellPhone"
        testContact.Email = "email"
        testContact.ID = 100
        testContact.ModuleID = 21
        testContact.Name = "Name"
        testContact.PhoneNumber = "PhoneNumber"
        testContact.Title = "Title"
        testContact.ContentItemId = 449

        Assert.AreEqual(8, target.GetUpdateParameterList(testContact).Count)

        Assert.AreEqual("@ID", target.GetUpdateParameterList(testContact)(0).ParameterName)
        Assert.AreEqual(100, target.GetUpdateParameterList(testContact)(0).Value)

        Assert.AreEqual("@Name", target.GetUpdateParameterList(testContact)(1).ParameterName)
        Assert.AreEqual("Name", target.GetUpdateParameterList(testContact)(1).Value)

        Assert.AreEqual("@Title", target.GetUpdateParameterList(testContact)(2).ParameterName)
        Assert.AreEqual("Title", target.GetUpdateParameterList(testContact)(2).Value)

        Assert.AreEqual("@PhoneNumber", target.GetUpdateParameterList(testContact)(3).ParameterName)
        Assert.AreEqual("PhoneNumber", target.GetUpdateParameterList(testContact)(3).Value)

        Assert.AreEqual("@Email", target.GetUpdateParameterList(testContact)(4).ParameterName)
        Assert.AreEqual("email", target.GetUpdateParameterList(testContact)(4).Value)

        Assert.AreEqual("@CellPhone", target.GetUpdateParameterList(testContact)(5).ParameterName)
        Assert.AreEqual("CellPhone", target.GetUpdateParameterList(testContact)(5).Value)

        Assert.AreEqual("@ContentItemID", target.GetUpdateParameterList(testContact)(6).ParameterName)
        Assert.AreEqual(449, target.GetUpdateParameterList(testContact)(6).Value)

        Assert.AreEqual("@ModuleID", target.GetUpdateParameterList(testContact)(7).ParameterName)
        Assert.AreEqual(21, target.GetUpdateParameterList(testContact)(7).Value)
    End Sub
#End Region
#Region "---TestGetInsertParameterList---"
    <TestMethod()>
    Public Sub TestGetInsertParameterList()
        Dim target As New DotNetNuke.Modules.GeminorumSoftwareContacts.ContactToSQLParameterConverter
        Dim testContact As New DotNetNuke.Modules.GeminorumSoftwareContacts.Contact
        testContact.CellPhoneNumber = "CellPhone"
        testContact.Email = "email"
        testContact.ID = 100
        testContact.ModuleID = 21
        testContact.Name = "Name"
        testContact.PhoneNumber = "PhoneNumber"
        testContact.Title = "Title"
        testContact.ContentItemId = 449

        Assert.AreEqual(7, target.GetInsertParameterList(testContact).Count)

        Assert.AreEqual("@Name", target.GetInsertParameterList(testContact)(0).ParameterName)
        Assert.AreEqual("Name", target.GetInsertParameterList(testContact)(0).Value)

        Assert.AreEqual("@Title", target.GetInsertParameterList(testContact)(1).ParameterName)
        Assert.AreEqual("Title", target.GetInsertParameterList(testContact)(1).Value)

        Assert.AreEqual("@PhoneNumber", target.GetInsertParameterList(testContact)(2).ParameterName)
        Assert.AreEqual("PhoneNumber", target.GetInsertParameterList(testContact)(2).Value)

        Assert.AreEqual("@Email", target.GetInsertParameterList(testContact)(3).ParameterName)
        Assert.AreEqual("email", target.GetInsertParameterList(testContact)(3).Value)

        Assert.AreEqual("@CellPhone", target.GetInsertParameterList(testContact)(4).ParameterName)
        Assert.AreEqual("CellPhone", target.GetInsertParameterList(testContact)(4).Value)

        Assert.AreEqual("@ContentItemID", target.GetInsertParameterList(testContact)(5).ParameterName)
        Assert.AreEqual(449, target.GetInsertParameterList(testContact)(5).Value)

        Assert.AreEqual("@ModuleID", target.GetInsertParameterList(testContact)(6).ParameterName)
        Assert.AreEqual(21, target.GetInsertParameterList(testContact)(6).Value)
    End Sub
#End Region

End Class